<template>
	<view class="beijingse">
		<!-- 头部 -->
		<view class="toububox mainpadding ">
			<view class="flexbetween"  @click="login" v-if="!is_login">
				<view class="flexleft">
					<image class="touxiang margin_right2" src="@/static/image/system/weidenglu.png" mode=""></image>
					<view class="bigtext xiaobai fonweight margin_right1">未登录，点击登录</view>
				</view>
				<u-icon name="arrow-right" color="#fff"></u-icon>
			</view>
			<view class="flexbetween" @click="jumper('/pages_mypage/gerenxx')" v-if="is_login">
				<view class="flexleft">
					<image class="touxiang margin_right2" :src="userInfo.avatar_text" mode=""></image>
					<view class="">
						<view class="flexleft">
							<view class="bigtext xiaobai fonweight margin_right1">{{userInfo.nickname}}</view>
							<view class="mbaibtn flexcenter" v-if="userInfo.level_text">{{userInfo.level_text}}</view>
						</view>
						<view class="flexleft margin_top1" @click.stop="copy(userInfo.invite_code)">
							<view class="strongtext xiaobai  margin_right1">邀请码：{{userInfo.invite_code}}</view>
							<image class="fuzhi" src="../static/image/system/fz.png" mode=""></image>
						</view>
					</view>
				</view>
				<u-icon name="arrow-right" color="#fff"></u-icon>
			</view>
			<view class="ffffff radius mainpadding margin_top">
				<view class="flexbetween"  @click="jumper('/pages_mypage/dingdan')">
					<view class="ershiba ">我的订单</view>
					<view class="flexright">
						<view class="strongtext xiaohui flexcenter margin_right2">查看全部订单</view>
						<u-icon name="arrow-right" color="#AFAFAF"></u-icon>
					</view>
				</view>
				<view class="margin_top5 flexbetween">
					<view class="ershiw flexcenter" @click="jumper('/pages_mypage/dingdan')">
						<view class="">
							<view class="ddicon">
								<image src="../static/image/system/qbdd.png" mode=""></image>
							</view>
							<view class="strongtext margin_top2">全部订单</view>
						</view>
					</view>
					<view class="ershiw flexcenter" @click="order1(1)">
						<view class="">
							<view class="ddicon">
								<image src="../static/image/system/dfk.png" mode=""></image>
							</view>
							<view class="strongtext margin_top2">待付款</view>
						</view>
					</view>
					<view class="ershiw flexcenter" @click="order1(2)">
						<view class="">
							<view class="ddicon">
								<image src="../static/image/system/dfh.png" mode=""></image>
							</view>
							<view class="strongtext margin_top2">待发货</view>
						</view>
					</view>
					<view class="ershiw flexcenter" @click="order1(3)">
						<view class="">
							<view class="ddicon">
								<image src="../static/image/system/dsh.png" mode=""></image>
							</view>
							<view class="strongtext margin_top2">待收货</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="mainpadding2" v-if="is_login">
			<view class="flexbetween">
				<view class="jfbox flexbetween" @click="jumper('/pages_mypage/wodejifen')">
					<view class="titletext fonweight" style="color:#FF5900;">{{userInfo.score}}</view>
					<view class="jbbtn">
						<view class="smalltext fonweight" style="color: #FF3A26;">积分</view>
					</view>
				</view>
				<view class="hdbox flexbetween" @click="jumper('/pages_mypage/wodehuok')">
					<view class="titletext fonweight" style="color:#FF5900;">{{userInfo.money}}</view>
					<view class="hkbtn">
						<view class="smalltext fonweight" style="color: #FF3A26;">货款</view>
					</view>
				</view>
			</view>
		</view>
		<view class="mainpadding2">
			<view class="mainpadding ffffff radius">
				<view class="flexbetween xiahuaxian" @click="jumper('/pages_homepage/shouhuodizhi')">
					<view class="flexleft">
						<view class="myicon margin_right2">
							<image src="../static/image/system/dz.png" mode=""></image>
						</view>
						<view class="sanshier xiaohei">地址管理</view>
					</view>
					<u-icon name="arrow-right" color="#C8C8C8"></u-icon>
				</view>
				<template v-if="is_login">
					<button class="dibubox" hover-class="none" open-type="contact" bindcontact="handleContact" session-from="sessionFrom">
						<view class="flexbetween xiahuaxian margin_top">
							<view class="flexleft">
								<view class="myicon margin_right2">
									<image src="../static/image/system/lxkf.png" mode=""></image>
								</view>
								<view class="sanshier xiaohei">联系客服</view>
							</view>
							<u-icon name="arrow-right" color="#C8C8C8"></u-icon>
						</view>
					</button>
				</template>
				
				<view class="flexbetween xiahuaxian margin_top" @click="jumper('/pages_mypage/yaoqinghy')">
					<view class="flexleft">
						<view class="myicon margin_right2">
							<image src="../static/image/system/yqhy1.png" mode=""></image>
						</view>
						<view class="sanshier xiaohei">邀请好友</view>
					</view>
					<u-icon name="arrow-right" color="#C8C8C8"></u-icon>
				</view>
				<view class="flexbetween xiahuaxian margin_top" @click="jumper('/pages_mypage/wodetuandui')">
					<view class="flexleft">
						<view class="myicon margin_right2">
							<image src="../static/image/system/wdtd.png" mode=""></image>
						</view>
						<view class="sanshier xiaohei">我的团队</view>
					</view>
					<u-icon name="arrow-right" color="#C8C8C8"></u-icon>
				</view>
				<view class="flexbetween xiahuaxian margin_top" @click="jumper('/pages_mypage/ceochengzzn')">
					<view class="flexleft">
						<view class="myicon margin_right2">
							<image src="../static/image/system/czjh.png" mode=""></image>
						</view>
						<view class="sanshier xiaohei">CEO成长计划</view>
					</view>
					<u-icon name="arrow-right" color="#C8C8C8"></u-icon>
				</view>
				<view class="flexbetween xiahuaxian margin_top" @click="jumper('/pages_mypage/guanyuwomen?type=4')">
					<view class="flexleft">
						<view class="myicon margin_right2">
							<image src="../static/image/system/gywm.png" mode=""></image>
						</view>
						<view class="sanshier xiaohei">关于我们</view>
					</view>
					<u-icon name="arrow-right" color="#C8C8C8"></u-icon>
				</view>
				<view class="flexbetween margin_top" @click="jumper('/pages_mypage/yijianfankui')">
					<view class="flexleft">
						<view class="myicon margin_right2">
							<image src="../static/image/system/yjfk.png" mode=""></image>
						</view>
						<view class="sanshier xiaohei">意见反馈</view>
					</view>
					<u-icon name="arrow-right" color="#C8C8C8"></u-icon>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				is_login: false,
				userInfo: {},
			}
		},
		onShow() {
			this.is_login = httpRequest.checkIsLogin();
			if (this.is_login) {
				this.init()
			}
		},
		onShareAppMessage() {
			let _this = this
			return {
				title: "好物商城",
				path: "pages/homepage?code=" + uni.getStorageSync("invite_code"),
			}
		},
		onShareTimeline: function() {
			return {
				title: "好物商城",
				path: "pages/homepage?code=" + uni.getStorageSync("invite_code"),
			}
		},
		methods: {
			init() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.userInfo = res.data
					uni.setStorageSync("invite_code",res.data.invite_code)
				})
			},
			login() {
				uni.navigateTo({
					url: "/pages/login/login"
				})
			},
			// 跳转我的订单
			order1(i) {
				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return false
				}
				uni.navigateTo({
					url: '/pages_mypage/dingdan?i=' + i
				})
			},
			jumper(url) {
				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return false
				}
				uni.navigateTo({
					url: url
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.myicon {
		width: 38rpx;
		height: 38rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.hdbox {
		width: 48%;
		padding: 32rpx 25rpx 32rpx 34rpx;
		background-size: 100% 100%;
		box-sizing: border-box;
		background-image: url('https://solarmini.yuntaiqi.com/uploads/20240109/3dafd70f8df61618851184dbf3d1567e.png');
	}

	.hkbtn {
		padding: 10rpx 48rpx 10rpx 26rpx;
		background-size: 100% 100%;
		box-sizing: border-box;
		background-image: url('../static/image/system/hk.png');
	}

	.jbbtn {
		padding: 10rpx 48rpx 10rpx 26rpx;
		background-size: 100% 100%;
		box-sizing: border-box;
		background-image: url('../static/image/system/jf.png');
	}

	.jfbox {
		width: 48%;
		padding: 32rpx 25rpx 32rpx 34rpx;
		background-size: 100% 100%;
		box-sizing: border-box;
		background-image: url('https://solarmini.yuntaiqi.com/uploads/20240109/365317faefd2808ee177340534b8a25f.png');
	}

	.fuzhi {
		width: 28rpx;
		height: 28rpx;
	}

	.ddicon {
		width: 45rpx;
		height: 40.56rpx;
		margin: auto;

		image {
			margin: auto;
			width: 100%;
			height: 100%;
		}
	}

	.mbaibtn {
		padding: 0 10rpx;
		height: 39rpx;
		background: rgba(255, 255, 255, 0.1);
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		font-size: 20rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		border: 1rpx solid #FFFFFF;
	}

	.touxiang {
		width: 110rpx;
		height: 110rpx;
		border-radius: 50rpx;
	}

	.toububox {
		background: linear-gradient(0deg, #f8f8f8 0%, #fc8545 100%);
	}
</style>